% V20210224 - 14.1.3 Populating a place holder with GW controls example INCLUDE "GW.bas" % Create a page. p = GW_NEW_PAGE() % Prepare title bar string. Title$ = GW_ADD_BAR_TITLE$("Placeholder Example") % Add title to page. GW_ADD_TITLEBAR(p, Title$) % Array containing a list of controls. ARRAY.LOAD controls$[], "#Choose a control", "checkbox", "radio control", "flip switch", "input line" % Add a selectbox and a listener on it. sbox = GW_ADD_SELECTBOX(p, "", controls$[]) GW_ADD_LISTENER(p, sbox, "change", "SEL") % And a placeholder. p_h = GW_ADD_PLACEHOLDER(p) % Now show the page. GW_RENDER(p) DO % Wait for user action. r$ = GW_WAIT_ACTION$() % User changed the select box. IF r$ = "SEL" % What control did the user pick? choice = GW_GET_VALUE(sbox) % Title line in selectbox = no choice made IF choice = 1 % do nothing % Checkbox ELSEIF choice = 2 html$ = GW_OPEN_GROUP$() FOR i = 1 TO 3 html$ += GW_ADD_CHECKBOX$(">Option "+INT$(i)) NEXT html$ += GW_CLOSE_GROUP$() GW_FILL_PLACEHOLDER(p, p_h, html$) GW_RENDER(p) % needed to show the changes! GW_MODIFY(sbox, "selected", INT$(choice)) % Radio ELSEIF choice = 3 html$ = GW_OPEN_GROUP$() GW_USE_THEME_CUSTO_ONCE("inline") html$ += GW_ADD_RADIO$(0, "001") papa = GW_LAST_ID() FOR i = 2 TO 4 GW_USE_THEME_CUSTO_ONCE("inline") html$ += GW_ADD_RADIO$(papa, "00"+INT$(i)) NEXT html$ += GW_CLOSE_GROUP$() GW_FILL_PLACEHOLDER(p, p_h, html$) GW_RENDER(p) % needed to show the changes! GW_MODIFY(sbox, "selected", INT$(choice)) % Flip switch ELSEIF choice = 4 html$ = GW_ADD_FLIPSWITCH$("Light status", "off", ">on") GW_FILL_PLACEHOLDER(p, p_h, html$) GW_RENDER(p) % needed to show the changes! GW_MODIFY(sbox, "selected", INT$(choice)) % Input line ELSEIF choice = 5 GW_USE_THEME_CUSTO_ONCE("color=b") html$ = GW_ADD_INPUTLINE$("What's up Doc?", "Nothing much") GW_FILL_PLACEHOLDER(p, p_h, html$) GW_RENDER(p) % needed to show the changes! GW_MODIFY(sbox, "selected", INT$(choice)) ENDIF ENDIF % end of selectbox changed % End when BACK key is pressed. UNTIL r$ = "BACK" END "End of Placeholder example."